<template>
	<div>
		<el-breadcrumb separator="/">
      <el-breadcrumb-item v-if="this.$route.query.sign === 'testPlan'" :to="{ path: '/TestPlan' }"><i class="el-icon-s-home" style="margin-right: 15px;font-size: 16px"></i>测试方案</el-breadcrumb-item>
      <el-breadcrumb-item v-if="this.$route.query.sign === 'runningTest'" :to="{ path: '/RunningTest' }"><i class="el-icon-s-home" style="margin-right: 15px;font-size: 16px"></i>运行测试</el-breadcrumb-item>
      <el-breadcrumb-item><i class="el-icon-menu" style="margin-right: 15px;font-size: 16px"></i>{{testPlanName}}</el-breadcrumb-item>
    </el-breadcrumb>
		<div class="info">
      <audio hidden ref="audio" loop :src="music">您的浏览器暂不支持播放音频</audio>
      <el-row>
        <el-col :span="7">
          <el-card shadow="always">
            <el-row><div class="rectangularBar"></div><div class="heardTitle">{{workePosit}}</div></el-row>
            <el-carousel height="83px" v-loading="dataLoading[0]" arrow="never" indicator-position="none">
              <el-carousel-item v-for="item in instrumentData" :key="item[0].instr_id">
                <div class="instrument">
                  <div class="flex" v-for="(item1, index1) in item" :key="index1">
                    <span>{{item1.instr_name}}</span>
                    <span>
                      <span style="margin-top: 15px;" class="statusIcon" :style="{'background-color':(item1.online_status === '在线' ?'#009641':'#D91B1B')}"></span>
                      <span>{{item1.online_status}}</span>
                    </span>
                  </div>
                </div>
              </el-carousel-item>
            </el-carousel>
          </el-card>
        </el-col>
        <el-col :span="17" style="padding-left: 20px;">
          <el-card shadow="always">
            <el-row style="margin-bottom: 5px">
              <div class="rectangularBar"></div><div class="heardTitle">试验参数</div>
              <el-button type="text" :disabled="pauseButton" style="float:right;" class="global_add" icon="el-icon-edit-outline" @click="editTestParams">编辑所有参数</el-button>
            </el-row>
            <el-form v-loading="dataLoading[0]" :model="testParams" ref="testParamsForm" size="small" label-position="top" :rules="testParamsRules">
              <el-row>
                <el-col :span="6" class="queryParams">
                  <el-form-item label="委试号：" prop="testNumber" :rules="[{ required: true, message: '请输入委试号', trigger: 'blur' }]">
                    <el-input :disabled="pauseButton" v-model="testParams.testNumber" size="mini" clearable></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="6" class="queryParams">
                  <el-form-item label="温度：" prop="temperature" :rules="[{ required: true, message: '请输入温度', trigger: 'blur' },{ validator: validateValue, trigger: 'blur' }]">
                    <el-input :disabled="editDisable" v-model="testParams.temperature" size="mini" clearable><template slot="append">&nbsp;&nbsp;℃&nbsp;&nbsp;</template></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="6" class="queryParams">
                  <el-form-item label="相对湿度：" prop="humidity" :rules="[{ required: true, message: '请输入相对湿度', trigger: 'blur' },{ validator: validateValue, trigger: 'blur' }]">
                    <el-input :disabled="editDisable" v-model="testParams.humidity" size="mini" clearable><template slot="append">%RH</template></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="6" class="queryParams">
                  <el-form-item label="大气压：" prop="pressure" :rules="[{ required: true, message: '请输入大气压', trigger: 'blur' },{ validator: validateValue, trigger: 'blur' }]">
                    <el-input :disabled="editDisable" v-model="testParams.pressure" size="mini" clearable><template slot="append">kpa</template></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
            </el-form>
          </el-card>
        </el-col>
      </el-row>
      <el-card shadow="always" style="margin-top: 15px">
        <el-button type="primary" :loading="startLoading" v-if="startButton" @click="verify('testParamsForm')">启动试验</el-button>
        <el-button type="primary" v-if="pauseButton" @click="pauseTest">暂停试验</el-button>
        <el-button type="primary" v-if="continueButton" @click="continueTest()">继续试验</el-button>
        <el-button type="danger" v-if="stopButton" @click="stopTest" style="float: right">停止试验</el-button>
        <div class="params">
          <el-row>
            <el-col :span="6">
              <el-row class="testTitle">开始时间</el-row><el-row class="numberOfTestStatis" style="color: #9090ED;">{{startTime}}</el-row>
            </el-col>
            <el-col :span="6">
              <el-row class="testTitle">运行时长</el-row><el-row class="numberOfTestStatis" style="color: #54DE5C;">{{runningTime}}<span class="unitOfStatistics">分钟</span></el-row>
            </el-col>
            <el-col :span="6">
              <el-row class="testTitle">报警</el-row><el-row class="alamNumber"  style="color: #FD7A88;">{{alarmCount}}<span class="unitOfStatistics">次</span></el-row>
            </el-col>
            <el-col :span="6" style="text-align: center;">
              <el-row class="testTitle">试验进度</el-row>
              <el-row style="margin-top: 25px">
                <el-progress :percentage="percent" :text-inside="true" :stroke-width="22" color="#F5BA54"></el-progress>
              </el-row>
            </el-col>
          </el-row>
        </div>
        <el-row class="status">当前试验信息</el-row>
        <el-table :data="currentPartInfo" border style="margin-top: 15px" :header-cell-style="{background:'#F7F7FB'}">
          <el-table-column label="试验部位" show-overflow-tooltip>
              <template slot-scope="props">
                    <el-tag v-if="props.row.flagBit.length!=0">标志位</el-tag>
                    <span >{{props.row.partName}}</span>
                  </template>
          </el-table-column>
          <el-table-column prop="pressGround" label="加压-接地部位" show-overflow-tooltip></el-table-column>
          <el-table-column prop="statusName" label="合/分闸" show-overflow-tooltip></el-table-column>
          <el-table-column prop="testVolt" label="应施电压(kV)" show-overflow-tooltip></el-table-column>
          <el-table-column prop="testKindCn" label="试验类型" align="center" show-overflow-tooltip></el-table-column>
          <el-table-column prop="ifPositiveCn" label="正负极" align="center" show-overflow-tooltip></el-table-column>
          <el-table-column prop="testVal" label="实测电压(kVp)" align="center" show-overflow-tooltip></el-table-column>
          <el-table-column prop="discharge" label="是否放电" align="center">
            <template slot-scope="scope">
              <div v-if="scope.row.discharge === 0">是</div>
              <div v-if="scope.row.discharge === 1">否</div>
            </template>
          </el-table-column>
        </el-table>
        <el-row class="status">
          <el-col :span="12" style="font-size:18px;">所有试验信息
            <el-switch v-model="switchStatus" inactive-text="隐藏" active-color="#6C59DD" @change="switchChange" style="width: 100px"></el-switch>
          </el-col>
          <el-col :span="12" style="text-align:right;"><el-button v-if="startButton" type="text" class="global_add" @click="selectPartVisible = true">选择试验部位</el-button></el-col>
        </el-row>
        <el-table v-show="showPartData" :span-method="arraySpanMethod" v-loading="dataLoading[0]" ref="showPartData" :data="testPartList" border highlight-current-row style="margin-top: 15px" :header-cell-style="{background:'#F7F7FB'}">
          <el-table-column type=index label="序号" width="80" align="center" show-overflow-tooltip></el-table-column>
          <el-table-column  label="试验部位" align="center" prop="partName" show-overflow-tooltip>
          </el-table-column>
          <el-table-column prop="pressGround" label="加压-接地部位" show-overflow-tooltip></el-table-column>
          <el-table-column prop="flagBit" label="标志位" show-overflow-tooltip></el-table-column>
          <el-table-column prop="testVolt" label="应施电压(kV)" show-overflow-tooltip></el-table-column>
          <!-- <el-table-column prop="testKindCn" label="试验类型" show-overflow-tooltip></el-table-column> -->
          <el-table-column 
        prop="testKind"
        label="试验类型"
        width="150"
        :filters="[{ text: '工频耐受电压试验', value: '工频耐受电压试验' }, { text:'雷电冲击耐受电压试验', value: '雷电冲击耐受电压试验' },{ text:'工频耐受电压试验(湿)', value: '工频耐受电压试验(湿)' }]"
        :filter-method="filterTag"
        filter-placement="bottom-end">
        <template slot-scope="scope">
          <el-tag
            :type="scope.row.testKindCn === '工频耐受电压试验' ? 'primary' : 'success'"
            disable-transitions>{{scope.row.testKindCn}}</el-tag>
        </template>
      </el-table-column>
          <el-table-column label="正负极" prop="ifPositiveCn" align="center" show-overflow-tooltip></el-table-column>
          <el-table-column label="累计试验次数" align="center">
            <template slot-scope="scope">
              <el-popover placement="right" trigger="hover">
                <el-table v-if="scope.row.testKindCn === '雷电冲击耐受电压试验'" :data="scope.row.testRecord.testValue" border style="width: 750px" :header-cell-style="{background:'#F7F7FB'}">
                  <el-table-column label="序号" align="center" width="60">
                    <template slot-scope="scope">
                      <div :style="{'color':(scope.row.testResult === 0 ?'#D9001B':'#000000')}">{{scope.$index+1}}</div>
                    </template>
                  </el-table-column>
                  <el-table-column label="实测电压值(kVp)">
                    <template slot-scope="scope">
                      <div :style="{'color':(scope.row.UpTestResult === 0 ?'#D9001B':'#000000')}">{{scope.row.UpTestVal}}</div>
                    </template>
                  </el-table-column>
                  <el-table-column label="波头时间(t)">
                    <template slot-scope="scope">
                      <div :style="{'color':(scope.row.wavet1TestResult === 0 ?'#D9001B':'#000000')}">{{scope.row.wavet1TestVal}}</div>
                    </template>
                  </el-table-column>
                  <el-table-column label="波尾时间(t)">
                    <template slot-scope="scope">
                      <div :style="{'color':(scope.row.wavet2TestResult === 0 ?'#D9001B':'#000000')}">{{scope.row.wavet2TestVal}}</div>
                    </template>
                  </el-table-column>
                  <el-table-column label="截断时间(t)">
                    <template slot-scope="scope">
                      <div :style="{'color':(scope.row.TCTestResult === 0 ?'#D9001B':'#000000')}">{{scope.row.TCTestVal}}</div>
                    </template>
                  </el-table-column>
                  <el-table-column label="过冲(%)">
                    <template slot-scope="scope">
                      <div :style="{'color':(scope.row.overshootTestResult === 0 ?'#D9001B':'#000000')}">{{scope.row.overshootTestVal}}</div>
                    </template>
                  </el-table-column>
                </el-table>
                <el-table v-else :data="scope.row.testRecord.testValue" border style="width: 200px" :header-cell-style="{background:'#F7F7FB'}">
                  <el-table-column label="序号" align="center" width="60">
                    <template slot-scope="scope">
                      <div :style="{'color':(scope.row.testResult === 0 ?'#D9001B':'#000000')}">{{scope.$index+1}}</div>
                    </template>
                  </el-table-column>
                  <el-table-column label="实测电压值(kVp)">
                    <template slot-scope="scope">
                      <div :style="{'color':(scope.row.testResult === 0 ?'#D9001B':'#000000')}">{{scope.row.testVal}}</div>
                    </template>
                  </el-table-column>
                </el-table>
                <div slot="reference" style="color: #5344AA">{{scope.row.testRecord.testCon}}</div>
              </el-popover>
            </template>
          </el-table-column>
          <el-table-column label="异常次数" align="center">
            <template slot-scope="scope">
              <div :style="{'color':(scope.row.dischargeCon > 0 ?'#D9001B':'#000000')}">{{scope.row.dischargeCon}}</div>
            </template>
          </el-table-column>
          <el-table-column label="试验状态" align="center">
            <template slot-scope="scope">
              <div :style="{'color':(scope.row.testStatus === '已完成'?'#000000':(scope.row.testStatus === '试验中'?'#6C59DD':'#02790E'))}">{{scope.row.testStatus}}</div>
            </template>
          </el-table-column>
        </el-table>
      </el-card>
      <el-dialog title="提示" :visible.sync="causeVisible" :close-on-click-modal="false" :close-on-press-escape="false" :show-close="false" width="40%">
        <el-row style="margin:30px 0 20px 40px">试验异常，请选择异常原因，并做出下一步操作</el-row>
        <el-row style="margin:30px 0 20px 40px">异常原因：<span style="color: #D9001B;">{{abnormalCauses}}</span></el-row>
        <el-radio-group v-model="failCase" style="margin: 0 0 60px 40px">
          <el-radio label="试验方原因">试验方原因</el-radio>
          <el-radio label="试品原因">试品原因</el-radio>
        </el-radio-group>
        <el-row style="margin-bottom: 10px">
          <el-col :span="8"><el-button type="danger" @click="causeFailStop">停止试验</el-button></el-col>
          <el-col :span="8" style="text-align: center"><el-button type="primary" @click="goOnTest">继续试验</el-button></el-col>
          <el-col :span="8" style="text-align: right"><el-button type="primary" @click="causeFailContiue">选择部位</el-button></el-col>
        </el-row>
      </el-dialog>
      <el-dialog title="提示" :visible.sync="stopVisible" :close-on-click-modal="false" :close-on-press-escape="false" :show-close="false" width="40%">
        <el-row style="font-size:15px;margin:30px 0 20px 40px">是否确定终止当前试验，终止后不可继续试验</el-row>
        <span slot="footer" class="dialog-footer">
          <el-button @click="stopVisible=false;causeVisible=true;" style="width:140px;margin-right: 20px">取 消</el-button>
          <el-button type="primary" style="width:140px" @click="stopTest">确 定</el-button>
        </span>
      </el-dialog>
      <el-dialog title="提示" :visible.sync="opcStatusVisable" :close-on-click-modal="false" :close-on-press-escape="false" :show-close="false" width="40%">
        <el-row style="font-size:15px;margin:30px 0 20px 40px">合闸状态已做完，请确认切换分闸完毕后点击继续试验按钮</el-row>
        <span slot="footer" class="dialog-footer">
          <el-button type="primary" style="width:140px" @click="continueTest()">继续试验</el-button>
        </span>
      </el-dialog>
      <el-dialog title="提示" :visible.sync="pauseVisable" :close-on-click-modal="false" :close-on-press-escape="false" :show-close="false" width="40%">
        <el-row style="font-size:15px;margin:30px 0 20px 40px">试验异常：{{yichangdesc}}，已暂停测试</el-row>
        <span slot="footer" class="dialog-footer">
          <el-button type="primary" style="width:140px" @click="pauseVisable=false">确定</el-button>
        </span>
      </el-dialog>
      <el-dialog title="提示" :visible.sync="suspendVisable" :close-on-click-modal="false" :close-on-press-escape="false" :show-close="false" width="40%">
        <el-radio-group v-model="ifGround" style="margin: 0 0 60px 40px">
          <el-radio label="0">不接地</el-radio>
          <el-radio label="1">接地</el-radio>
        </el-radio-group>
        <span slot="footer" class="dialog-footer">
          <el-button v-if="suspendType==0" @click="suspendVisable=false" style="width:140px;margin-right: 20px">取 消</el-button>
          <el-button type="primary" style="width:140px" @click="suspendTest">确 定</el-button>
        </span>
      </el-dialog>
      <el-dialog title="提示" :visible.sync="selPartVisible" :close-on-click-modal="false" :close-on-press-escape="false" :before-close="selectHandleClose" width="40%">
        <el-row style="margin-left:30px">请选择从哪个加压接地位置开始试验</el-row>
        <el-row style="margin:10px 0 20px 30px">试品当前状态：{{partStatus}}&nbsp;&nbsp;&nbsp;&nbsp;当前试验：{{currentTest}}&nbsp;&nbsp;&nbsp;&nbsp;当前试验位置：{{currentPart}}</el-row>
        <el-row style="margin:0 0 40px 30px;"><el-cascader v-model="startPart" :props="cateProps" :options="options" clearable style="width: 50%"></el-cascader></el-row>
        <span slot="footer" class="dialog-footer">
          <el-button @click="selectHandleClose" style="width:140px;margin-right: 20px">取 消</el-button>
          <el-button type="primary" style="width:140px" @click="sendTestPartList">确 定</el-button>
        </span>
      </el-dialog>
      <el-dialog title="提示" :visible.sync="ballDistVisible" :close-on-click-modal="false" :close-on-press-escape="false" :show-close="false" width="40%">
        <el-row style="margin-left:30px">请输入球隙距离</el-row>
        <el-row style="margin:0 0 40px 30px;"><el-input v-model="ballDistance" clearable></el-input></el-row>
        <span slot="footer" class="dialog-footer">
          <el-button type="primary" style="width:140px" @click="sendTestPartList">确 定</el-button>
        </span>
      </el-dialog>
      <el-dialog :visible.sync="successVisible" width="35%" :close-on-click-modal="false" :close-on-press-escape="false" :show-close="false" top="30vh">
        <div class="successInfo">{{successInfo}}<el-row><i class="el-icon-circle-check" style="margin:40px 0;font-size: 100px;color:#03A613;font-weight: bolder;"></i></el-row></div>
        <el-table :data="confirmInstrument" size="small" border style="width: 100%" :header-cell-style="{background:'#F7F7FB'}">
          <el-table-column property="instr_name" label="设备名称" show-overflow-tooltip></el-table-column>
          <el-table-column label="设备型号" property="model"></el-table-column>
          <el-table-column label="设备编号" property="instr_number"></el-table-column>
          <el-table-column label="工位名称" property="station_name"></el-table-column>
          <el-table-column label="设备状态">
            <template slot-scope="props">
              <el-select v-model="props.row.status" size="small" style="width:100%">
                <el-option label="正常" value="1"></el-option>
                <el-option label="异常" value="0"></el-option>
              </el-select>
            </template>
          </el-table-column>
        </el-table>
        <span slot="footer" class="dialog-footer">
          <el-button type="primary" style="width:140px" @click="afterCofirmInstStatus">确 定</el-button>
        </span>
      </el-dialog>
      <el-dialog :visible.sync="confirmVisible" :close-on-click-modal="false" :close-on-press-escape="false" :before-close="handleClose" width="75%">
        <el-row class="confirmTitle">为确保试验安全，请务必仔细确认以下信息是否有误</el-row>
        <el-row><div class="rectangularBar"></div><div class="heardTitle">公共参数</div></el-row>
        <el-form :model="confirmParams" ref="confirmParams" size="small" label-width="112px" style="margin-top: 10px">
          <el-row>
            <el-col :span="6"><el-form-item label="委试号：" prop="testNumber" :rules=" { required: true, message: '请输入委试号', trigger: 'blur' }">
              <el-input v-model="confirmParams.testNumber" clearable></el-input>
            </el-form-item></el-col>
            <el-col :span="6"><el-form-item label="试品模板："><span class="text">{{confirmParams.tpltName}}</span></el-form-item></el-col>
            <!-- <el-col :span="6"><el-form-item label="试品名称："><span class="text">{{confirmParams.prodName}}</span></el-form-item></el-col> -->
            <el-col :span="6"><el-form-item label="适用海拔(m)："><span class="text">{{confirmParams.seaLevel}}</span></el-form-item></el-col>
          <!-- </el-row>
          <el-row> -->
            <el-col :span="6"><el-form-item label="海拔参数m："><span class="text">{{confirmParams.kaM}}</span></el-form-item></el-col>
            <el-col :span="6"><el-form-item label="相对湿度(%RH)："><span class="text">{{confirmParams.humidity}}</span></el-form-item></el-col>
            <el-col :span="6"><el-form-item label="大气压(kpa)："><span class="text">{{confirmParams.pressure}}</span></el-form-item></el-col>
            <el-col :span="6"><el-form-item label="温度(℃)："><span class="text">{{confirmParams.temperature}}</span></el-form-item></el-col>
          </el-row>
          <el-row>
            <el-col :span="24"><el-form-item label="试验类型："><span class="text">{{confirmParams.testKind}}</span></el-form-item></el-col>
          </el-row>
          <el-row>
            <el-col :span="24"><el-form-item label="试验依据标准："><span class="text">{{confirmParams.gjbName}}</span></el-form-item></el-col>
          </el-row>
        </el-form>
        <el-row><div class="rectangularBar"></div><div class="heardTitle">试验参数</div></el-row>
        <el-tabs v-model="activeName" style="margin: 10px 20px 0px 20px">
          <el-tab-pane label="雷电冲击耐受电压试验" name="first" v-if="showliEquip">
            <el-form :model="liEquipParams" ref="liEquipParams" label-width="135px" style="margin: 10px 0px 0 10px">
              <el-row>
                <el-col :span="8"><el-form-item label="充电时间(s)："><span class="textEquip">{{liEquipParams.chargeTime}}</span></el-form-item></el-col>
                <el-col :span="8"><el-form-item label="首次充电电压(kVp)："><span class="textEquip">{{liEquipParams.chargeVolt}}</span></el-form-item></el-col>
                <el-col :span="8"><el-form-item label="计数器(次)："><span class="textEquip">{{liEquipParams.chargeCnt}}</span></el-form-item></el-col>
              </el-row>
              <el-row>
                <el-col :span="8"><el-form-item label="连续放电："><span class="textEquip">{{liEquipParams.ifDischarge}}</span></el-form-item></el-col>
                <el-col :span="8"><el-form-item label="老练次数："><span class="textEquip">{{liEquipParams.bufferCnt}}</span></el-form-item></el-col>
                <el-col :span="8"><el-form-item label="C(μF)："><span class="textEquip">{{liEquipParams.paramC}}</span></el-form-item></el-col>
              </el-row>
              <el-row>
                <el-col :span="8"><el-form-item label="C1(pF)："><span class="textEquip">{{liEquipParams.paramC1}}</span></el-form-item></el-col>
                <el-col :span="8"><el-form-item label="Rf(Ω)："><span class="textEquip">{{liEquipParams.paramRf}}</span></el-form-item></el-col>
                <el-col :span="8"><el-form-item label="Rt(Ω)："><span class="textEquip">{{liEquipParams.paramRt}}</span></el-form-item></el-col>
              </el-row>
            </el-form>
            <div class="formItem"><el-form :model="liEquipForm" :rules="liEquipParamsRules" ref="liEquipForm" label-width="0px" size="small" :inline-message="true">
              <el-table :data="liEquipForm.liEquipTableData" size="small" border style="width: 100%;margin-bottom:20px" :header-cell-style="{background:'#F7F7FB'}">
                <el-table-column property="part_name" label="试验部位" show-overflow-tooltip></el-table-column>
                <el-table-column label="原始电压(kVp)">
                  <template slot-scope="props">
                    <el-form-item :prop="'liEquipTableData.' + props.$index + '.origin_volt'" :rules="[{ required: true, message: '请输入原始电压', trigger: 'blur'},{ validator: validateValue, trigger: 'blur'}]">
                      <el-input v-model="props.row.origin_volt" size="small" placeholder="请输入原始电压" clearable></el-input>
                    </el-form-item>
                  </template>
                </el-table-column>
                <el-table-column label="是否校大气">
                  <template slot-scope="props">
                    <el-select v-model="props.row.if_calair" size="small" v-if="props.row.if_calair !== '2'" style="width:100%">
                      <el-option label="是" value="1"></el-option>
                      <el-option label="否" value="0"></el-option>
                    </el-select>
                    <span v-if="props.row.if_calair === '2'">不允许校大气</span>
                  </template>
                </el-table-column>
                <el-table-column label="试验电压百分比(%)">
                  <template slot-scope="props">
                    <el-form-item :prop="'liEquipTableData.' + props.$index + '.percent_volt'" :rules="[{ required: true, message: '请输入试验电压百分比', trigger: 'blur'},{ validator: validateValue, trigger: 'blur'}]">
                      <el-input v-model="props.row.percent_volt" size="small" placeholder="请输入试验电压百分比" clearable></el-input>
                    </el-form-item>
                  </template>
                </el-table-column>
                <el-table-column property="remark" label="备注" show-overflow-tooltip></el-table-column>
              </el-table>
            </el-form></div>
          </el-tab-pane>
          <el-tab-pane label="工频耐受电压试验" name="second" v-if="showACEquip">
            <el-form :model="acEquipParams" ref="acEquipParams" label-width="140px" size="small" style="margin: 10px 0px 0 10px">
              <el-row>
                <el-col :span="8"><el-form-item label="采样间隔(s)："><span class="textEquip">{{acEquipParams.collectInterval}}</span></el-form-item></el-col>
                <el-col :span="8"><el-form-item label="耐压时间(s)："><span class="textEquip">{{acEquipParams.withstandTime}}</span></el-form-item></el-col>
                <!-- <el-col :span="8"><el-form-item label="高速设置(%)："><span class="textEquip">{{acEquipParams.highSpeed}}</span></el-form-item></el-col>
              </el-row>
              <el-row>
                <el-col :span="8"><el-form-item label="低速设置(%)："><span class="textEquip">{{acEquipParams.lowSpeed}}</span></el-form-item></el-col> -->
              </el-row>
            </el-form>
            <div class="formItem"><el-form :model="acEquipForm" :rules="liEquipParamsRules" ref="acEquipForm" label-width="0px" size="small" :inline-message="true">
              <el-table :data="acEquipForm.acEquipTableData" size="small" border style="width: 100%;margin-bottom:20px" :header-cell-style="{background:'#F7F7FB'}">
                <el-table-column property="part_name" label="试验部位" show-overflow-tooltip></el-table-column>
                <el-table-column label="原始电压(kVp)">
                  <template slot-scope="props">
                    <el-form-item :prop="'acEquipTableData.' + props.$index + '.origin_volt'" :rules="[{ required: true, message: '请输入原始电压', trigger: 'blur'},{ validator: validateValue, trigger: 'blur'}]">
                      <el-input v-model="props.row.origin_volt" size="small" placeholder="请输入原始电压" clearable></el-input>
                    </el-form-item>
                    </template>
                </el-table-column>
                <el-table-column label="是否校大气">
                  <template slot-scope="props">
                    <el-select v-model="props.row.if_calair" size="small" v-if="props.row.if_calair !== '2'" style="width:100%">
                      <el-option label="是" value="1"></el-option>
                      <el-option label="否" value="0"></el-option>
                    </el-select>
                    <span v-if="props.row.if_calair === '2'">不允许校大气</span>
                  </template>
                </el-table-column>
                <el-table-column label="试验电压百分比(%)">
                  <template slot-scope="props">
                    <el-form-item :prop="'acEquipTableData.' + props.$index + '.percent_volt'" :rules="[{ required: true, message: '请输入试验电压百分比', trigger: 'blur'},{ validator: validateValue, trigger: 'blur'}]">
                      <el-input v-model="props.row.percent_volt" size="small" placeholder="请输入试验电压百分比" clearable></el-input>
                    </el-form-item>
                  </template>
                </el-table-column>
                <el-table-column property="remark" label="备注" show-overflow-tooltip></el-table-column>
              </el-table>
            </el-form></div>
          </el-tab-pane>
          <el-tab-pane label="工频耐受电压试验(湿)" name="fourth" v-if="showACWet">
            <el-form :model="acWetEquipParams" ref="acWetEquipParams" label-width="140px" size="small" style="margin: 10px 0px 0 10px">
              <el-row>
                <el-col :span="8"><el-form-item label="采样间隔(s)："><span class="textEquip">{{acWetEquipParams.collectInterval}}</span></el-form-item></el-col>
                <el-col :span="8"><el-form-item label="耐压时间(s)："><span class="textEquip">{{acWetEquipParams.withstandTime}}</span></el-form-item></el-col>
                <!-- <el-col :span="8"><el-form-item label="高速设置(%)："><span class="textEquip">{{acWetEquipParams.highSpeed}}</span></el-form-item></el-col>
              </el-row>
              <el-row>
                <el-col :span="8"><el-form-item label="低速设置(%)："><span class="textEquip">{{acWetEquipParams.lowSpeed}}</span></el-form-item></el-col> -->
                <el-col :span="8"><el-form-item label="雨水电导率(μS/cm)："><span class="textEquip">{{acWetEquipParams.rainElect}}</span></el-form-item></el-col>
                <el-col :span="8"><el-form-item label="水平分量(mm/min)："><span class="textEquip">{{acWetEquipParams.horizCompont}}</span></el-form-item></el-col>
              <!-- </el-row>
              <el-row> -->
                <el-col :span="8"><el-form-item label="垂直分量(mm/min)："><span class="textEquip">{{acWetEquipParams.verticalCompont}}</span></el-form-item></el-col>
                <el-col :span="8"><el-form-item label="水温(℃)："><span class="textEquip">{{acWetEquipParams.waterTemp}}</span></el-form-item></el-col>
              </el-row>
            </el-form>
            <div class="formItem"><el-form :model="acWetEquipForm" :rules="liEquipParamsRules" ref="acWetEquipForm" label-width="0px" size="small" :inline-message="true">
              <el-table :data="acWetEquipForm.wetACTableData" size="small" border style="width: 100%;margin-bottom:20px" :header-cell-style="{background:'#F7F7FB'}">
                <el-table-column property="part_name" label="试验部位" show-overflow-tooltip></el-table-column>
                <el-table-column label="原始电压(kVp)">
                  <template slot-scope="props">
                    <el-form-item :prop="'wetACTableData.' + props.$index + '.origin_volt'" :rules="[{ required: true, message: '请输入原始电压', trigger: 'blur'},{ validator: validateValue, trigger: 'blur'}]">
                      <el-input v-model="props.row.origin_volt" size="small" placeholder="请输入原始电压" clearable></el-input>
                    </el-form-item>
                  </template>
                </el-table-column>
                <el-table-column label="是否校大气">
                  <template slot-scope="props">
                    <el-select v-model="props.row.if_calair" size="small" v-if="props.row.if_calair !== '2'" style="width:100%">
                      <el-option label="是" value="1"></el-option>
                      <el-option label="否" value="0"></el-option>
                    </el-select>
                    <span v-if="props.row.if_calair === '2'">不允许校大气</span>
                  </template>
                </el-table-column>
                <el-table-column label="试验电压百分比(%)">
                  <template slot-scope="props">
                    <el-form-item :prop="'wetACTableData.' + props.$index + '.percent_volt'" :rules="[{ required: true, message: '请输入试验电压百分比', trigger: 'blur'},{ validator: validateValue, trigger: 'blur'}]">
                      <el-input v-model="props.row.percent_volt" size="small" placeholder="请输入试验电压百分比" clearable></el-input>
                    </el-form-item>
                  </template>
                </el-table-column>
                <el-table-column property="remark" label="备注" show-overflow-tooltip></el-table-column>
              </el-table>
            </el-form></div>
          </el-tab-pane>
          <el-tab-pane label="气候防护试验" name="third" v-if="showDefend">
            <el-form :model="defendParams" ref="defendParams" label-width="130px" size="small" style="margin: 10px 0px 0 10px">
              <el-row>
                <el-form-item label="防护等级"><span class="textEquip">{{defendParams.protectId}}</span></el-form-item>
              </el-row>
              <el-row>显示试品尺寸(仅支持防护等级为IPX3 IPX4 IPX5 IPX5W IPX6)</el-row>
              <el-table v-if="defendParams.defendTableData.length !== 0" :data="defendParams.defendTableData" border style="width: 100%" :header-cell-style="{background:'#F7F7FB'}">
                <el-table-column property="protectLevel" label="防护等级"></el-table-column>
                <el-table-column label="试品长度(m)">
                  <template slot-scope="props">
                    <div class="defend"><el-form-item label-width="0px" :prop="'defendTableData.' + props.$index + '.productLength'" :rules="[{ required: true, message: '请输入试品长度', trigger: 'blur'},{ validator: validateValue, trigger: 'blur'}]">
                      <el-input v-model="props.row.productLength" size="small" placeholder="请输入试品长度" clearable></el-input>
                    </el-form-item></div>
                  </template>
                </el-table-column>
                <el-table-column label="试品宽度(m)">
                  <template slot-scope="props">
                    <div class="defend"><el-form-item label-width="0px" :prop="'defendTableData.' + props.$index + '.productWidth'" :rules="[{ required: true, message: '请输入试品宽度', trigger: 'blur'},{ validator: validateValue, trigger: 'blur'}]">
                      <el-input v-model="props.row.productWidth" size="small" placeholder="请输入试品宽度" clearable></el-input>
                    </el-form-item></div>
                  </template>
                </el-table-column>
                <el-table-column label="试品高度(m)">
                  <template slot-scope="props">
                    <div class="defend"><el-form-item label-width="0px" :prop="'defendTableData.' + props.$index + '.productHeight'" :rules="[{ required: true, message: '请输入试品高度', trigger: 'blur'},{ validator: validateValue, trigger: 'blur'}]">
                      <el-input v-model="props.row.productHeight" size="small" placeholder="请输入试品高度" clearable></el-input>
                    </el-form-item></div>
                  </template>
                </el-table-column>
              </el-table>
            </el-form>
          </el-tab-pane>
        </el-tabs>
        <el-row style="margin-top: 10px"><div class="rectangularBar"></div><div class="heardTitle">设备运行状态</div></el-row>
        <el-table v-loading="dataLoading[2]" :data="confirmInstrument" size="small" border style="width: 100%; margin-top: 10px" :header-cell-style="{background:'#F7F7FB'}">
          <el-table-column property="instr_name" label="设备名称" show-overflow-tooltip></el-table-column>
          <el-table-column label="设备型号" property="model"></el-table-column>
          <el-table-column label="设备编号" property="instr_number"></el-table-column>
          <el-table-column label="工位名称" property="station_name"></el-table-column>
          <el-table-column label="设备状态">
            <template slot-scope="props">
              <el-select v-model="props.row.status" size="small" style="width:100%">
                <el-option label="正常" value="1"></el-option>
                <el-option label="异常" value="0"></el-option>
              </el-select>
            </template>
          </el-table-column>
        </el-table>
        <el-row style="text-align: center;margin-top: 20px"><el-checkbox v-model="checked" @change="whetherClick = !checked">以上信息确认无误</el-checkbox></el-row>
        <el-dialog width="30%" title="提示" :visible.sync="innerVisible" append-to-body :close-on-click-modal="false" :close-on-press-escape="false" :show-close="false">
          <el-row style="margin-left:30px">检测到设备状态选择了异常，请确认是否开始试验?</el-row>
          <span slot="footer" class="dialog-footer">
            <el-button class="textBtn" @click="innerVisible = false">取消</el-button>
            <el-button type="primary" :loading="startLoading" @click="saveValidate()">确定</el-button>
          </span>
        </el-dialog>
        <span slot="footer" class="dialog-footer">
          <el-button type="primary" :loading="startLoading" :disabled="whetherClick" style="width:140px" @click="beforStartTest">确 定</el-button>
        </span>
      </el-dialog>
      <el-dialog title="提示" :visible.sync="remindVisible" width="30%" :close-on-click-modal="false" :close-on-press-escape="false" :show-close="false">
        <el-row style="font-size:15px;margin:30px 0 20px 40px">{{messageRemind}}</el-row>
        <span slot="footer" class="dialog-footer">
          <el-button v-if="remindFlag===403" @click="remindVisible=false;" style="width:140px;margin-right: 20px">取消</el-button>
          <el-button :loading="startLoading" v-if="remindFlag===403" type="primary" style="width:140px" @click="saveValidate('continue')">确定</el-button>
          <el-button :loading="startLoading" v-if="remindFlag===300" type="primary" style="width:140px" @click="saveValidate('sure')">确定</el-button>
        </span>
      </el-dialog>
      <el-dialog title="选择试验部位" :visible.sync="selectPartVisible" :close-on-click-modal="false" :close-on-press-escape="false" width="40%">
        <template>
          <!-- <el-tabs v-model="testKind">
            <el-tab-pane
    :key="item.testKind"
    v-for="item in selectionPartData" 
    :label="item.testKindCn"
    :name="item.testKind"
  > -->
  <el-table  :data="selectionPartData" row-key="index" ref="selectionPartData" height="600" @selection-change="selectionChange" style="width: 100%;margin-top:20px" border :header-cell-style="{background:'#F7F7FB'}">
                <el-table-column type="selection" width="50" :reserve-selection="true"></el-table-column>
                <el-table-column label="序号" type="index" width="50"></el-table-column>
                <el-table-column prop="testKindCn" label="试验类型" align="center" show-overflow-tooltip></el-table-column>
                <el-table-column prop="partName" label="试验部位" show-overflow-tooltip></el-table-column>
                <el-table-column prop="pressGround" label="加压-接地部位" show-overflow-tooltip></el-table-column>
                <el-table-column label="正负极" prop="ifPositiveCn" align="center" show-overflow-tooltip></el-table-column>
              </el-table>
  <!-- </el-tab-pane>
         </el-tabs> -->
        </template>
        
             
        <span slot="footer" class="dialog-footer">
          <el-button @click="selectPartVisible=false;" class="textBtn" style="width:140px;margin-right: 20px">取 消</el-button>
          <el-button type="primary" style="width:140px" @click="confirmSelectPart">确 定</el-button>
        </span>
      </el-dialog>
		</div>
	</div>
</template>
<script>
import alarmMusic from '../../assets/music/alarm.mp3'
import moment from 'moment';
import Bus from '../../public/eventBus.js'
import myMqtt from '@/public/mqtt.js';
import dayjs from 'dayjs';
import sessionStorage from '../../public/storage.js';
import Vue from 'vue';
const uuid = require('node-uuid');
export default {
	data() {
    this.validateValue = (rule, value, callback) => {
      if (!/^\d+(\.\d{1,2})?$/.test(value)) {
        callback(new Error('输入值非法，请输入整数或至多两位小数'));
      }
      callback();
    };
    return {
      testKind:0,
      suspendVisable:false,
      ifGround:"0",
      successInfo: '恭喜，试验完成！',
      liEquipParamsRules: {}, // 参数规则校验
      acWetEquipForm: {
        wetACTableData: [], // 工频耐受电压试验(湿)电压部位参数表
      },
      pauseVisable:false,
      opcStatusVisable: false, // 合分闸部位切换弹窗标记
      music: alarmMusic, // 报警音乐
      allTestPartList: [], // 所有试验部位原始数据
      recordId: '', // 记录id
      ballDistance: 0, // 球隙距离
      ballDistVisible: false, // 输入球隙距离弹窗标记
      editDisable: false, // 试验参数中温度、湿度、大气压是否可编辑标记
      oldTestNumber: '', // 之前输入的委试号
      kaData: [], // 启动测试计算出的数据
      cateProps: { // 选择从哪个加压接地部位开始试验数据渲染格式
        value: 'value',
        lable: 'label',
        children: 'children'
      },
      yichangdesc:'',
      remindFlag: null, // 计算Ka出错标记
      remindVisible: false, // 计算ka出错弹窗
      messageRemind: '', // 启动前计算的值超出范围提示
      showDefend: false, // 防护试验显示
      defendParams: {
        protectId: '', // 防护测试id
        defendTableData: [] // 防护编辑表格数据
      },
      multSelect: [], // 多选
      selectionPartData: [], // 选择试验部位表格数据
      selectPartVisible: false, // 选择试验部位弹窗显示
      startLoading: false, // 开始运行按钮加载
      innerVisible: false, // 仪器选择异常弹窗
      whetherClick: true, // 勾选以上信息确认无误标记
      showACWet: false, // 展示湿工频
      currentPartInfo: [], // 当前试验信息
      confirmVisible: false, // 启动试验前确认说明
      confirmParams: { // 启动试验前确认公共参数
        gjbName: '', // 试验依据标准
        kaM: null, // 海拔参数m
        prodName: '', // 试品名称
        seaLevel: null, // 试用海拔
        testKind: '', // 试验类型
        tpltName: '', // 试品模板
        testNumber: '', // 委试号
        temperature: '', // 温度
        humidity: '', // 湿度
        pressure: '' // 大气压
      },
      checked: false, // 确认信息复选框
      confirmInstrument: [], // 设备运行状态确认表格数据
      showliEquip: false, // 展示雷电
      confimTableData: [], // 试验前确认数据表格
      liEquipForm: {
        liEquipTableData: [], // 试验前确认雷电数据表格
      },
      acEquipForm: {
        acEquipTableData: [], // 试验前确认工频数据表格
      },
      liEquipParams: { // 雷电试验参数 
        ballInterval: null,
        bufferCnt: null, // 老练次数
        chargeCnt: null, // 计数器
        chargeTime: null, // 充电时间
        chargeVolt: null, // 充电电压
        ifDischarge: '', // 是否放电
        paramC: '',
        paramC1:'',
        paramRf: '',
        paramRt: ''
      },
      acEquipParams: { // 工频试验参数
        collectInterval: null, // 采样间隔
        withstandTime: null, // 耐压时间
        highSpeed: null, // 高速设置
        lowSpeed: null, // 低速设置
        testKind: 1 // 测试类型代码
      },
      acWetEquipParams: {
        testKind: 2, // 测试类型代码
        collectInterval: null, // 采样间隔
        horizCompont: null, // 水平分量
        rainElect: null, // 雨水导电率
        verticalCompont: null, // 垂直分量
        waterTemp: null, // 水温
        withstandTime: null, // 耐压时间
        highSpeed: null, // 高速设置
        lowSpeed: null, // 低速设置
      },
      showACEquip: false, // 展示干工频tab
      startPart: [], // 选择开始部位
      options: [], // 加压接地部位列表
      partStatus: '', // 试品当前状态
      currentTest: '', // 当前试验
      currentPart: '', // 当前试验位置
      selPartVisible: false, // 选择开始试验部位弹窗
      successVisible: false, // 试验成功弹窗提示
      failCase: '试验方原因', // 选择失败原因
      stopVisible: false, // 终止试验弹窗提示
      reslutflag:0,
      causeVisible: false, // 试验异常弹窗提示
      workePosit: '', // 工位名称
      startTime: '', // 开始
      runningTime: 0, // 运行
      percent: 0, // 百分比
      alarmCount: 3, // 告警
      testParams:{// 测试参数表单
        testNumber: '', // 委试号
        temperature: '', // 温度
        humidity: '', // 湿度
        pressure: '' // 大气压
      },
      suspendType :0,
      switchStatus: false, // 开关显示所有试验信息
      showPartData: true, // 显示当前所有数据
      testPartList: [], // 试验部位表格数据
      instrumentData:[],  //测试仪器
      instanceId: '', // 测试实例
      prodId: '', // 试品类型id
      tpltId: '', // 模板id
      dataLoading: [false,false,false,false],
      activeName: 'first', // 当前激活的tab页
      startButton: true,  //启动测试按钮
      stopButton: false,  //停止测试按钮
      pauseButton: false, //暂停测试按钮
      continueButton: false,  //继续测试按钮
      testPlanName: '',   //方案名称
      testParamsRules:{},
      row: '', 
      abnormalCauses: ''
    };
	},
	methods: {
    arraySpanMethod({ row, column, rowIndex, columnIndex }) {
        if (row.tpType === 2) { 
          if (columnIndex === 0) {
            return [1,1];
          }
          else if (columnIndex === 1) {
            return [1,10];
          } 
          else if (columnIndex === 2) {
            return [0,0];
          }
          else if (columnIndex === 3) {
            return [0,0];
          }
          else if (columnIndex === 4) {
            return [0,0];
          }
          else if (columnIndex === 5) {
            return [0,0]}
           else if (columnIndex === 6) {
            return [0,0]}
            else if (columnIndex === 7) {
            return [0,0]}
          else if (columnIndex === 8) {
            return [0,0]}
            else if (columnIndex === 9) {
            return [0,0]}
        }
      },
    handleClick(tab, event) {
      console.log(tab, event);
    },
    filterTag(value, row) {
      return row.testKindCn === value;
    },
    switchChange() {
      this.showPartData = !this.switchStatus
      this.setCurrent(this.row);
    },
    async init(){
      console.info('-----------------页面接收参数---------------');
      console.info(this.$route.query);
      this.testPlanName = this.$route.query.planName; // 方案名称
      this.showPartData = !this.switchStatus; // 默认显示所有试验信息
      if (this.$route.query.sign === 'testPlan') { // 从测试方案进入
        this.startTime = '-';
        this.runningTime = 0;
        this.percent = 0;
        this.alarmCount = 0;
        this.testParams.testNumber = this.$route.query.testNumber;
        this.testParams.temperature = this.$route.query.temperature;
        this.testParams.humidity = this.$route.query.humidity;
        this.testParams.pressure = this.$route.query.pressure;
        await this.getRunningTestInfo();
      } else {
        console.info('hhhihhhhhhhhhhhhhhhhhhh');
        this.oldTestNumber = this.$route.query.oldTestNumber;
        this.testParams.testNumber = this.$route.query.testNumber;
        this.confirmParams.testNumber = this.$route.query.testNumber;
        this.instanceId = this.$route.query.instanceId;
        this.runningTime = this.$route.query.duration;
        if(Number(this.$route.query.runningStatus) === 0){ //测试实例运行状态暂停
          this.pauseButton = false;
          this.continueButton = true;
        }else{ // 测试实例运行状态正在运行
          this.pauseButton = true;
          this.continueButton = false;
          this.timerClock(this.runningTime);
        }
        this.stopButton = true;
        this.startButton = false;
        await this.getRunningTestInfo();
        if (dayjs(this.$route.query.beginTime).format('MM-DD HH:mm')==='Invalid Date') {
          this.startTime = this.$route.query.beginTime;
        } else {
          this.startTime = dayjs(this.$route.query.beginTime).format('MM-DD HH:mm');
        }
        this.percent = Number(this.$route.query.schedule); //运行进度
        this.alarmCount = Number(this.$route.query.alarmCout);//报警次数
        await this.getConfimParams();
      }
    },
    // 报警选择停止
    causeFailStop () {
      this.causeVisible=false;
      this.stopVisible=true;
      this.reslutflag=1;
      this.$refs.audio.pause(); 
      this.$flag.setFlag(false)
    },
    // 报警选择继续保存报警原因
    async causeFailContiue () {
      this.reslutflag=1;
      this.$refs.audio.pause();
      const params = {
        testKind: this.currentPartInfo[0].testKind,
        dischargeRemark: this.causeVisible,
        recId: this.recordId
      }
      // const res = await this.$http.put("/runningTest/addExceptionCauses", params,);
      // if (res.code === 200) {
        this.selPartVisible = true;
        this.causeVisible=false;
      // }
      this.$flag.setFlag(false)
    },
    //  高亮当前行
    setCurrent (row) {
      this.$refs.showPartData.setCurrentRow(row);
    },
    // 改变委试号
    async changeTestNumber(){
      console.info('改变委试号');
      if (this.oldTestNumber !== this.testParams.testNumber) { // 委试号进行更改
        let params={
          testNumber: this.testParams.testNumber
        }
        let ret = await this.$http.get("/runningTest/judgeTestNumber",{params,});
        if (ret.code !== 200) {
          this.$message.warning('委试号重复，请检查并重新输入');
          return 403;
        }
        params = this.prepareParams();
        params.info.newTestNumber = this.testParams.testNumber;
        params.info.test_number = this.oldTestNumber;
        params.info.oldInstanceId = this.instanceId;
        params.info.instance_id = uuid.v1();
        console.info('------------委试号传参---------------')
        console.info(params);
        ret = await this.$http.put("/runningTest/updateTestRunningParams",params);
        if (ret.code === 200) {
          this.oldTestNumber = this.testParams.testNumber;
        }
      }
      if (this.$route.query.update === '1') { // 如果是电压参数进行更改获取选择加压接地位置。。。。。。。。。。。。。
        this.selPartVisible = true;
        await this.getPositionData();
        return 403;
      }
      return 200;
    },
    // 获取雷电设备参数
    async getACInstParams() {
      let params;
      console.info(this.confirmInstrument)
      for (let i=0; i<this.confirmInstrument.length; i++) {
        if (/雷电冲击耐受电压试验设备/.exec(this.confirmInstrument[i].kind_name)!== null && /雷电冲击耐受电压试验设备/.exec(this.confirmInstrument[i].kind_name)[0] === '雷电冲击耐受电压试验设备') {
          params = {
            instrId: this.confirmInstrument[i].instr_id
          }
          const ret = await this.$http.get("/testPlan/getInstrumentParams",{params,});
          console.info(ret)
          for(let j=0; j<ret.result.length; j++) {
            if(/^C\(μF\)$/.test(ret.result[j].param_name) === true) {
              this.liEquipParams.paramC = ret.result[i].param_val;
            }
            if(/^C1\(pF\)$/.test(ret.result[j].param_name) === true) {
              this.liEquipParams.paramC1 = ret.result[i].param_val;
            }
            if(/^Rf\(Ω\)$/.test(ret.result[j].param_name) === true) {
              this.liEquipParams.paramRf = ret.result[i].param_val;
            }
            if(/^Rt\(Ω\)$/.test(ret.result[j].param_name) === true) {
              this.liEquipParams.paramRt = ret.result[i].param_val;
            }
          }
          break
        }
      }
    },
    // 选择部位弹窗关闭
    async selectHandleClose(){
      if (this.$route.query.update === '1') { // 更新电压参数
        this.selPartVisible = false;
        this.causeVisible = false;
      } 
      this.$route.query.update = 0;
    },
    // 弹窗关闭操作
    handleClose(){
      this.checked = false;
      this.whetherClick = true;
      this.confirmVisible = false;
    },
    // 选择试验部位后根据选择的部位和试验类型筛选数据渲染所有试验信息表格
    confirmSelectPart(){
      let partList = [];
      for(let i=0; i<this.allTestPartList.length; i++){
        const index = this.multSelect.findIndex((value)=>{
          return value.partName == this.allTestPartList[i].partName && value.pressGround == this.allTestPartList[i].pressGround 
            && value.testKind == this.allTestPartList[i].testKind && value.ifPositive == this.allTestPartList[i].ifPositive
        })
        if (index !== -1) {
          partList.push(this.allTestPartList[i]);
        }
      }
      this.testPartList = partList;
      console.info("}}}}}}}}}}}}}}");
      console.info(this.testPartList);
      this.selectPartVisible = false;
      this.$refs.selectionPartData.clearSelection();
    },
    //  多选
		selectionChange (val) {
			this.multSelect = val;
		},
    // 下发球隙距离数据
    async sendBallParams() {
      const params = {
        type: 'ballParams',
        ballDistance: this.balldistance
      }
      const ret = await this.$http.post("/runningTest/sendMqttRelease",params);
      if (ret.code === 200) {
        this.ballDistVisible = false;
        this.pauseButton = true;
        this.continueButton = false;
      }
    },
    // 试验异常后确定从选择的试验部位开始试验
    async sendTestPartList () {
      const params = this.prepareParams();
      const oldTestKind = params.publicParam.testKind;
      const index = this.testPartList.findIndex((value) => {
        return value.position_id == this.startPart[1]
      })
      let partListArry=[];
      let partList = '';
      let testKind = [];
      // 将部位positionId去重拼接成字符串（主要是针对雷电）；将试验类型进行排序
      for (let i=index; i<this.testPartList.length; i++) {
        const repetIndex = partListArry.findIndex((value) => {
          return value.position_id == this.testPartList[i].position_id
        })
        if (repetIndex == -1) {
          partListArry.push(JSON.parse(JSON.stringify(this.testPartList[i])))
        }
        const kindIndex = testKind.findIndex((item) => {
          return item == this.testPartList[i].testKind
        })
        if (kindIndex === -1) {
          testKind.push(this.testPartList[i].testKind);
        }
      }
      params.publicParam.testKind = testKind;
      for (let i=0; i<partListArry.length; i++) {
        partList += '\'' + partListArry[i].position_id + '\','
      }
      partList = partList.substr(0,partList.length-1);
      params.testPartList = partList;
      console.info(params);
      const ret = await this.$http.post("/runningTest/sendPartInstanceData", params);
      if (ret.code == 200) {
        if (this.currentPartInfo[0].testKind === 3) { // 当前试验信息类型是雷电时，先将当前试验部位状态变成已完成
          const postionIndex = this.testPartList.findIndex((value) => {
            return value.position_id == this.currentPartInfo[0].position_id && value.ifPositive == this.currentPartInfo[0].ifPositive
          })
          console.info(postionIndex)
          if (postionIndex !== -1) {
            this.testPartList[postionIndex].testStatus = '已完成';
          }
        }
        this.selPartVisible = false;
        this.ballDistance = 0;
        this.pauseButton = true;
        this.continueButton = false;
        // 如果选择报警的部位并且该部位是负极，试验从负极开始，正极已完成；否则选择什么部位将该部位变成试验中
        if (this.currentPartInfo[0].ifPositiveCn == '-' && this.currentPartInfo[0].position_id == this.startPart[1]) {
          this.setCurrent(this.testPartList[index+1]);
          this.row = this.testPartList[index+1]
          this.testPartList[index+1].testStatus = '试验中';
          console.info("333333333333333");
        } else {
          console.info("444444444444444444444");
          this.testPartList[index].testStatus = '试验中';
          this.row = this.testPartList[index]
          this.setCurrent(this.testPartList[index]);
          this.currentPartInfo = [];
          this.currentPartInfo.push(this.testPartList[index]);
        }
        this.startPart = [];
      }
      params.publicParam.testKind = oldTestKind;
      this.$flag.setFlag(false)
    },
    // 根据当前试验状态获取选择加压接地部位列表
    async getPositionData(){
      const params = {
        instanceId: this.instanceId,
        testKind: this.currentPartInfo[0].testKind,
        opcStatus: this.currentPartInfo[0].opcStatus
      }
      const ret = await this.$http.get("/runningTest/getPositionData",{params,});
      this.options = ret.result;
    },
    // 获取运行测试等参数信息
    async getRunningTestInfo(){
      this.dataLoading[0] = true;
      const params = { // 根据启动按钮的状态判断是从方案还是实例查询信息
        planId: this.startButton === true? this.$route.query.planId : 0,
        instanceId: this.startButton === true? 0:this.instanceId
      };
      let ret={};
      // 根据edit标记判断是从编辑所有参数部分返回的数据进行渲染还是从api进行数据渲染；edit字段出现是进入编辑所有参数界面并点击保存按钮后
      if (this.$route.query.edit !== undefined && this.$route.query.edit === 'true') {
        console.info('============getRunningTestInfo传参============')
        ret.result = {
          tpltId: this.$route.query.tpltId,
          testPartInfo: this.$route.query.testPartInfo,
          testPartList: this.$route.query.testPartList,
          instrumentData: this.$route.query.instrumentData,
          temperature: this.$route.query.temperature,
          humidity: this.$route.query.humidity,
          pressure: this.$route.query.pressure,
        }
        this.allTestPartList = this.$route.query.allTestPartList;
      } else {
        console.info('============getRunningTestInfo接口============')
        ret = await this.$http.get("/runningTest/getRunningTestInfo",{params,});
        this.allTestPartList = ret.result.testPartList;
      }
      console.info(ret.result);
      this.instrumentData = ret.result.instrumentData;
      this.workePosit = this.instrumentData[0][0].station_name;
      this.testPartList = ret.result.testPartList;
      this.tpltId = ret.result.tpltId;
      // 当试验参数中的温度、相对湿度、大气压全部有数据进行数据渲染并设置不可编辑
      if (ret.result.temperature !== '' && ret.result.humidity !== '' && ret.result.pressure !== '') {
        this.testParams.temperature = ret.result.temperature;
        this.testParams.humidity = ret.result.humidity;
        this.testParams.pressure = ret.result.pressure;
        this.editDisable = true;
      }
      if (ret.result.testPartInfo){
        let flagInfo = 0; // 用于处理点击启动试验后未做完第一条部位，从导航栏运行测试进入显示数据标记
        if (JSON.stringify(ret.result.testPartInfo) === '{}') { // 获取到的testPartInfo是一个空对象
          for (let i=0; i<this.testPartList.length; i++) { // 根据所有试验信息表中的试验状态进行查找数据显示在当前试验信息表中
            console.info(i);
            console.info(this.testPartList[i]);
            if (this.testPartList[i].testStatus == '试验中') {
              ret.result.testPartInfo = this.testPartList[i];flagInfo = 1;break;
            }
            // console.info(this.testPartList[i+1].testStatus);
            if(i!=this.testPartList.length-1){
            if (this.testPartList[i].testStatus == '已完成' && this.testPartList[i+1].testStatus == '待试验') {
              ret.result.testPartInfo = this.testPartList[i+1];flagInfo= 1;
              this.testPartList[i+1].testStatus = '试验中';break;
            }
            }
          }
          if (flagInfo === 0) { // 针对刚点击启动测试后第一条数据还未做完
            ret.result.testPartInfo = this.testPartList[0];
          }
        }
        this.currentPartInfo.push(ret.result.testPartInfo);
        let testValueIndex = null; // 单条试验部位中累计实验次数表格数据最后一条数据下标
        this.currentPartInfo[0].testRecord.testValue.length === 0 ? testValueIndex = 0 :testValueIndex = this.currentPartInfo[0].testRecord.testValue.length-1;
        if (this.currentPartInfo[0].testRecord.testValue.length !== 0) { // 渲染当前试验信息中的实测电压、是否放电数据
          this.currentPartInfo[0].testVal = this.currentPartInfo[0].testRecord.testValue[testValueIndex].testVal;
          this.currentPartInfo[0].discharge = this.currentPartInfo[0].testRecord.testValue[testValueIndex].testResult;
        }
        // 查找当前试验信息在所有试验信息表中位置进行高亮显示
        const setIndex = this.testPartList.findIndex((value) => {
          return value.position_id == this.currentPartInfo[0].position_id
        })
        this.$nextTick(function(){
          this.setCurrent(this.testPartList[setIndex]);
          this.row = this.testPartList[setIndex]
        });
      } else if (ret.result.testPartInfo === undefined && this.$route.query.sign === 'runningTest') { // 刚启动试验成功后，从其他入口再次进入该页面
        this.currentPartInfo.push(this.testPartList[0]);
        this.testPartList[0].testStatus = '试验中';
      }
      this.dataLoading[0] = false;
      console.info("1234789")
      if (this.$route.query.edit !== undefined) {
        this.$route.query.edit = false;
      }
      console.info("=============================|||||||||||===============")
      console.info(this.allTestPartList)
      for(let i=0; i<this.allTestPartList.length; i++){
          let index = this.selectionPartData.findIndex((value)=>{
            return value.partName == this.allTestPartList[i].partName && value.pressGround == this.allTestPartList[i].pressGround 
            && value.testKind == this.allTestPartList[i].testKind && value.ifPositive == this.allTestPartList[i].ifPositive
          });
        this.selectionPartData.push({
            tpId: this.allTestPartList[i].tp_id,
            ifPositive: this.allTestPartList[i].ifPositive,
            ifPositiveCn: this.allTestPartList[i].ifPositiveCn,
            partName: this.allTestPartList[i].partName,
            pressGround: this.allTestPartList[i].pressGround,
            testKindCn:this.allTestPartList[i].testKindCn,
            testKind:this.allTestPartList[i].testKind,
        })
       
      }
     
      console.info("++++++++++++++++++++++++++++++++++++++");
      console.info(this.selectionPartData);
      console.info(this.testKind);
    },
    // 获取点击启动试验按钮后弹出的启动前确认参数
    async getConfimParams(){
      this.liEquipForm.liEquipTableData = [];
      this.acEquipForm.acEquipTableData = [];
      this.acWetEquipForm.wetACTableData = [];
      this.allDefendData = [];
      this.defendParams.defendTableData = [];
      this.dataLoading[1] = true;
      let voltParams;
      let reciveParams;
      // 点击启动按钮前进入过编辑所有参数界面并点保存按钮返回该界面则不调接口获取参数；点击启动试验后需要调接口获取数据
      if (this.$route.query.edit === undefined || this.startButton === false){
        const params = {
          planId: this.instanceId === ''? this.$route.query.planId : 0,
          instanceId: this.instanceId === ''? 0 : this.instanceId
        }
        const ret = await this.$http.get("/runningTest/getConfimParams",{params,});
        console.info('--------调接口---------')
        reciveParams = ret.result;
      } else {
        console.info('--------传参---------')
        reciveParams = this.$route.query.testParams;
      }
      console.info(reciveParams);
      this.confirmInstrument = reciveParams.instrument;
      this.prodId = reciveParams.confimParams.prod_id;
      this.confirmParams = reciveParams.confimParams;
      this.$set(this.confirmParams,"testNumber",this.testParams.testNumber);
      this.confirmParams.temperature = this.testParams.temperature;
      this.confirmParams.humidity = this.testParams.humidity;
      this.confirmParams.pressure = this.testParams.pressure;
      voltParams = reciveParams.voltParamsDemo;
      for (let i=0; i<voltParams.length; i++){ // 根据测试类型不同将数据存入雷电、干工频、湿工频电压参数表格中
        if (voltParams[i].test_kind === 1) {
          this.acEquipForm.acEquipTableData.push(JSON.parse(JSON.stringify(voltParams[i])));
        } else if (voltParams[i].test_kind === 3) {
          this.liEquipForm.liEquipTableData.push(JSON.parse(JSON.stringify(voltParams[i])));
        } else if (voltParams[i].test_kind === 2) {
          this.acWetEquipForm.wetACTableData.push(JSON.parse(JSON.stringify(voltParams[i])));
        }
      }
      const testKind = this.confirmParams.testKind.split(',');
      for (let i=0; i<testKind.length; i++){ // 根据已逗号分隔的试验类型进行tab页显示
        if (testKind[i] === '1') {
          this.showACEquip = true;
          this.activeName = 'second';
        } else if (testKind[i] === '3') {
          this.showliEquip = true;
          this.activeName = 'first';
        } else if (testKind[i] === '9') {
          this.showDefend = true;
          this.activeName = 'third';
        } else if (testKind[i] === '2') {
          this.showACWet = true;
          this.activeName = 'fourth';
        }
      }
      // 将试验类型数字转换为相对应的汉字进行显示
      this.confirmParams.testKind = this.confirmParams.testKind.replace(new RegExp('1','g'),'工频耐受电压试验');
      this.confirmParams.testKind = this.confirmParams.testKind.replace(new RegExp('2','g'),'工频耐受电压试验(湿)');
      this.confirmParams.testKind = this.confirmParams.testKind.replace(new RegExp('3','g'),'雷电冲击耐受电压试验');
      this.confirmParams.testKind = this.confirmParams.testKind.replace(new RegExp('9','g'),'气候防护试验');
      this.confirmParams.testKind = this.confirmParams.testKind.replace(new RegExp('5','g'),'辅助和控制回路的绝缘试验');
      if (reciveParams.LIParams !== undefined) { // 雷电参数
        this.liEquipParams = reciveParams.LIParams;
        await this.getACInstParams();
      }
      for (let i=0; i<reciveParams.ACParams.length; i++) { // 工频参数
        if (reciveParams.ACParams[i].testKind === 1) {
          this.acEquipParams = reciveParams.ACParams[i];
        } else {
          this.acWetEquipParams = reciveParams.ACParams[i];
        }
      }
      if (reciveParams.protectInfo !== undefined && reciveParams.protectInfo.protectData.length !==0 ) { // 气体防护等级
        this.defendParams.protectId = reciveParams.protectInfo.protectStr.protectLevel;
        this.allDefendData = reciveParams.protectInfo.protectData;
        for (let i=0; i<this.allDefendData.length; i++){
          if (this.allDefendData[i].protectId === 8 || this.allDefendData[i].protectId === 10 || this.allDefendData[i].protectId === 11 || this.allDefendData[i].protectId === 12 || this.allDefendData[i].protectId === 13) {
            this.defendParams.defendTableData.push(this.allDefendData[i]);
          }
        }
      }
      this.dataLoading[1] = false;
    },
    // 编辑所有参数按钮跳转界面
    editTestParams(){
      let query = {
        'sign': this.$route.query.sign,
        planName: this.testPlanName,
        planId: this.$route.query.planId,
        instanceId: this.instanceId,
        buttonSign: this.startButton,
        testNumber: this.testParams.testNumber,
        temperature: this.testParams.temperature,
        humidity: this.testParams.humidity,
        pressure: this.testParams.pressure,
        duration: this.runningTime,
        beginTime: this.startTime,
        schedule: this.percent,
        alarmCout: this.alarmCount,
        testPartInfo: this.currentPartInfo[0],
        testPartList: this.testPartList,
        instrumentData: this.instrumentData,
        tpltId: this.tpltId,
        allTestPartList: this.allTestPartList
      }
      if (this.$route.query.edit !== undefined && this.startButton===true) {
        query.testParams = this.$route.query.testParams;
        query.edit = true;
      }
      this.$router.push({
        path: '/TestParamsDisplay',
        query: query
      });
    },
    //计时器用于显示运行时间
    async timerClock(startingTime){
      this.runningTime = Number(startingTime);
      let timer = setInterval(() => {
        this.runningTime += 1;
        // if(this.percent === 100){
        //   this.stopTest();
        // }
        if(this.stopButton === false || this.pauseButton === false){ // 点击停止按钮或暂停按钮不进行计时
          clearInterval(timer);
        }
      }, 60000);
      this.$once('hook:beforeDestroy', () => {
				clearInterval(timer)
			})
    },
    // 获取测试过程中数据
    async getTestRecordData(data){
      console.info("||||||||||||||||");
      console.info(data);
      const reviceData = JSON.parse(data);
      console.log("获取测试过程中数据：");
      try {
        this.abnormalCauses = JSON.parse(reviceData.desc)[0]
      } catch(err) {
        err
      }
      this.recordId = reviceData.recordId; // 测试记录id
      let ifPositive = null; // 雷电正负极
      if (reviceData.type === 'testEnd' && reviceData.status === 'stop') { // 全部测试结束
        this.causeVisible = false;
        this.topVisible = true;
        this.startButton = true;
        this.stopButton = false;
        this.continueButton = false;
        this.pauseButton = false;
        // this.instanceId = '';
        this.stopVisible = false;
        this.successVisible = true;
        // this.testParams.testNumber = '';
      } else if (reviceData.type === 'dischargeStatus') { // 雷电设备没有放电，弹出球隙距离输入框
        this.pauseButton = false;
        this.continueButton = true;
        this.ballDistVisible = true;
        // 将当前部位存入选择选择当前试验部位开始数据中，球隙距离输入完毕后会从当前部位重新开始做试验
        this.startPart.push(reviceData.positionId,reviceData.positionId);
      } else if (reviceData.type === 'runningTest') {
        if(reviceData.status=='pause'){
          this.pauseVisable=true;
          this.startButton = false;
          this.stopButton = true;
          this.continueButton = true;
          this.pauseButton = false;
          this.yichangdesc=reviceData.dischargeDesc;
          console.info(this.instanceId);
          console.info(this.runningTime);
          await this.$http.put('/runningTest/addTestDuration',{"instanceId": this.instanceId, duration: Number(this.runningTime)})
        }
      }
      else if (reviceData.type === 'ldTestEnd') {
        const indexLd = this.testPartList.findIndex((value) => {
          return value.position_id == reviceData.positionId && value.ifPositive == reviceData.ifPositive;
        });
        this.testPartList[indexLd].testStatus = '已完成'
        if (indexLd+1 < this.testPartList.length) { // 如果当前试验不是最后一个试验更新状态
          console.info("如果当前试验不是最后一个试验更新状态"+this.testPartList[indexLd+1]);
          console.info("indexLd"+indexLd);
          this.testPartList[indexLd+1].testStatus = '试验中';
          this.setCurrent(this.testPartList[indexLd+1]);
          this.row = this.testPartList[indexLd+1];
          // this.$set(this.currentPartInfo,0,this.testPartList[indexLd+1]);
          // console.info(this.currentPartInfo);
        }
      }
      else if (reviceData.type === 'opcStatus' && (this.causeVisible !== true || this.selPartVisible !== true)) { // 合闸做完提示用户
        this.opcStatusVisable = true;
        this.continueButton = true;
        this.pauseButton = false;
      } else { // 调接口获取测试数据
        if (reviceData.testResult === 0) { // 测试结果异常
          this.$refs.audio.currentTime = 0;
          this.suspendType = 1;
          this.$refs.audio.play();
          this.$refs.audio.volume = 1;
          this.suspendVisable = true;
          this.pauseButton = false;
          this.continueButton = true;
          this.partStatus = this.currentPartInfo[0].statusName;
          this.currentTest = this.currentPartInfo[0].testKindCn;
          this.currentPart = this.currentPartInfo[0].partName;
          this.alarmCount = Number(this.alarmCount) + 1;
          await this.getPositionData();
        }
        const params = {
          'instanceId': this.instanceId,
          testKind: this.currentPartInfo[0].testKind,
          recId: reviceData.recordId,
          num: this.testPartList.length,
        }
        const ret = await this.$http.get("/runningTest/getRecordInfo",{params,});
        this.percent = Number(ret.result.progress);
        console.info("当前记录信息：")
        console.info(ret.result)
        console.info("状态："+ret.result.testStatus)
        reviceData.ifPositive === undefined? ifPositive = 2:ifPositive = Number(reviceData.ifPositive); // 工频试验没有ifPositive 因此赋值2，雷电有正1 负0
        // 根据网关返回的positionId和正负极信息在所有试验部位信息进行查找并高亮显示当前行
        console.info("部位ID："+reviceData.positionId+",正负级(正1 负0)："+ifPositive);
        const index = this.testPartList.findIndex((value) => {
          return value.position_id == reviceData.positionId && value.ifPositive == ifPositive;
        });
        console.info("第"+index+"几行");
        this.setCurrent(this.testPartList[index]);//高亮当前行
        this.row = this.testPartList[index]
        if (reviceData.ifPositive === 0 ||reviceData.ifPositive === 1) { // 如果返回的信息是雷电负极则将同部位的雷电正极试验状态修改为已完成
          console.info("返回的信息是雷电极"+reviceData.ifPositive);
          if(index!=0){
            this.testPartList[index-1].testStatus = '已完成'
          }
          this.$set(this.currentPartInfo,0,this.testPartList[index]);
        }
        this.$set(this.currentPartInfo,0,this.testPartList[index]);
        console.info(this.currentPartInfo);
        this.$set(this.currentPartInfo[0], "testVal", ret.result.recInfo.testVal);
        this.$set(this.currentPartInfo[0], "discharge", ret.result.recInfo.testResult);
        if(ret.result.ifDischarge == 1) {//判断是否放电
          this.testPartList[index].dischargeCon = Number(this.testPartList[index].dischargeCon) + 1;
        }
        this.testPartList[index].testRecord.testCon = Number(this.testPartList[index].testRecord.testCon) + 1;
        this.testPartList[index].testRecord.testValue.push(JSON.parse(JSON.stringify(ret.result.recInfo)));
        this.testPartList[index].testStatus = ret.result.testStatus;
        if (this.testPartList[index].testStatus === '已完成') { // 所有试验信息中当前试验部位如果已完成更新下一个部位为试验中并高亮显示
          console.info('---------进入已完成---------');
          if (index+1 < this.testPartList.length) { // 如果当前试验不是最后一个试验更新状态
            console.info("如果当前试验不是最后一个试验更新状态"+this.testPartList[index+1]);
            console.info("index"+index)
            this.testPartList[index+1].testStatus = '试验中';
            this.setCurrent(this.testPartList[index+1]);
            this.row = this.testPartList[index+1]
            if(this.testPartList[index+1].flag_bit.length!=0){
            console.info(this.testPartList[index+1].flag_bit);
            this.pauseTest();
          }
          }
        }
      }
      this.$flag.setFlag(false)
    },
    // 启动前及测试过程中参数拼接准备
    prepareParams(){
      let instrument = [];
      console.info("基本信息"+this.tpltId);
      for (let i=0; i<this.confirmInstrument.length; i++) { // 处理仪器信息
        instrument.push({
          instance_id: this.instanceId,
          instrument_id: this.confirmInstrument[i].instr_id,
          status: Number(this.confirmInstrument[i].status),
          address: this.confirmInstrument[i].address
        }) 
      }
      let params = {
        info: { // 基本信息
          instance_id: this.instanceId,
          plan_id: this.$route.query.planId,
          test_number: this.testParams.testNumber,
          test_user: JSON.parse(sessionStorage.getItem('userInfo')).user_id,
          tplt_id: this.tpltId,
          prod_id: this.prodId,
        },
        instrument: instrument,
        atmosphere: { // 温度、湿度、大气压
          instance_id: this.instanceId,
          RH: Number(this.testParams.humidity),
          ATM: Number(this.testParams.pressure),
          T: Number(this.testParams.temperature)
        },
        protectData: this.allDefendData, // 气体防护试验
        publicParam: this.confirmParams, // 公共参数
        ACParams: [] // 工频参数
      }
      // 将显示的试验类型中文替换成数字
      this.confirmParams.testKind = this.confirmParams.testKind.replace(/工频耐受电压试验\(湿\)/g.exec(this.confirmParams.testKind),'2');
      this.confirmParams.testKind = this.confirmParams.testKind.replace(/工频耐受电压试验/g.exec(this.confirmParams.testKind),'1');
      this.confirmParams.testKind = this.confirmParams.testKind.replace(/雷电冲击耐受电压试验/g.exec(this.confirmParams.testKind),'3');
      this.confirmParams.testKind = this.confirmParams.testKind.replace(/辅助和控制回路的绝缘试验/g.exec(this.confirmParams.testKind),'5');
      this.confirmParams.testKind = this.confirmParams.testKind.replace(/气候防护试验/g.exec(this.confirmParams.testKind),'9');
      let arr = this.confirmParams.testKind.split(',')
      arr.forEach(item => {
        item = Number(item)
      })
      arr.sort((a,b) => b - a)
      this.confirmParams.testKind = arr.join(',')
      let voltParams=[]; // 电压参数
      voltParams = voltParams.concat(this.acEquipForm.acEquipTableData,this.liEquipForm.liEquipTableData,this.acWetEquipForm.wetACTableData);
      for (let i=0; i<voltParams.length; i++) {
        voltParams[i].positionDate = [];
      }
      console.info(voltParams);
      console.info("(((((((((((((((((((((((((((%%%%%%%%%%%%%%%%%%%%%)))))))))))))))))))))))))))")
      if (this.testPartList.length !== this.allTestPartList.length) { // 当所有信息列表中的部位长度与原始数组长度不一致
        for (let i=0; i<voltParams.length;) { // 删除电压参数中所有试验信息列表中没有的部位
          let index = this.testPartList.findIndex((value) => {
            return value.tpId == voltParams[i].tp_id && value.testKind ==  voltParams[i].test_kind
          })
          if (index == -1) {
            this.$delete(voltParams, i)
          } else {
            i = i+1
          }
        }
        console.info("%%%%%%%%%%%%%%%%%%%%%")
        console.log('this.testPartList', this.testPartList);
        console.log('删除未选部位后', voltParams);
        let oldPositionId = '';
        for (let i=0; i<this.testPartList.length; i++) { // 根据类型和部位名称查找电压部位索引，将positionId存入
            let index = voltParams.findIndex((value) => {
              return value.tp_id == this.testPartList[i].tpId && this.testPartList[i].testKind == value.test_kind 
            })
            if (index !== -1) {
              let indexes = voltParams[index].positionDate.findIndex((value) => {
                return value.position_id == this.testPartList[i].position_id
              })
              if(indexes==-1){
              if(this.testPartList[i].ifPositive==1){
                voltParams[index].positionDate.push({position_id:this.testPartList[i].position_id,positive_sign:1})
              }
              if(this.testPartList[i].ifPositive==0){
                voltParams[index].positionDate.push({position_id:this.testPartList[i].position_id,positive_sign:0})
              }if(this.testPartList[i].ifPositive==2){
                voltParams[index].positionDate.push({position_id:this.testPartList[i].position_id,positive_sign:null})
              }
              console.info("6666666666666%%%%%%%%%%%%%%%%%%%%%%%%%%%%");
            }
             else{
              console.info(voltParams[index].positionDate[indexes]);
              voltParams[index].positionDate[indexes].positive_sign=2
              console.info("positionDate%%%%%%%%%%%%%%%%%%%%%%%%%%%%");
            }
            }
           
        }
      }
      params.voltParamsDemo = voltParams;
      console.info('--------------删除后选择部位---------------')
      console.info(params.voltParamsDemo)
      if (this.showACEquip === true) {
        params.ACParams.push(this.acEquipParams);
      }
      if (this.showliEquip === true) {
        params.LIParams = this.liEquipParams;
        params.LIParams.ballInterval = Number(this.ballDistance);
      }
      if (this.showACWet === true) {
        params.ACParams.push(this.acWetEquipParams);
      }
      return params;
    },
    // 启动或更新前计算ka
    async determineParameters(params,flag) {
      const detParams = {
        voltParamsDemo: JSON.stringify(params.voltParamsDemo),
        atmosphere: params.atmosphere,
        publicParam: {
          seaLevel: params.publicParam.seaLevel,
          kaM: params.publicParam.kaM
        },
        flag: flag === undefined? 0:1
      }
      console.info('-------detParams----------');
      console.info(detParams);
      const ret = await this.$http.get("/runningTest/determineParameters",{params:detParams,});
      this.remindFlag = ret.code
      if (ret.code === 200) {
        this.kaData = ret.kaData;
        for (let i=0; i<this.kaData.length; i++) { // api返回的kaData中出现null值则提示用户，无法启动试验
          if (this.kaData[i]==null) {
            this.$message.error('参数存在问题，无法计算出ka，请检查参数！');
            this.startLoading = false;
            return 400;
          }
        }
      } else if (ret.code === 403) {
        this.messageRemind = ret.message;
        this.remindVisible = true;
        this.startLoading = false;
        return 403;
      } else if (ret.code === 300) {
        this.messageRemind = ret.message;
        this.remindVisible = true;
        this.startLoading = false;
        return 300;
      }
      return 200;
    },
    //启动测试创建测试实例
    async saveInstance(flag){
      let ret;
      this.startLoading = true;
      this.startTime = '-';     //开始时间初始化
      this.runningTime = '-';   //运行时间初始化
      this.percent = 0;         //百分比初始化
      this.alarmCount = 0;      //告警初始化
      this.innerVisible = false;
      this.$message.success('正在启动测试,请稍后!');
      this.instanceId = uuid.v1();
      let judeParams={ // 判断委试号是否重复
        testNumber: this.confirmParams.testNumber
      }
      ret = await this.$http.get("/runningTest/judgeTestNumber",{params:judeParams});
      if (ret.code !== 200) {
        this.$message.error('委试号重复，请检查并重新输入');
        this.startLoading = false;
        return 400;
      }
      const params = this.prepareParams();
      console.log('params',params);
      // 计算kaData时如果出现403进行提示，客户点击确认时将flag置1；如果出现300只做提示，客户点击继续正常开始
      if (flag === undefined || flag === 'continue') {
        const result = await this.determineParameters(params,flag);
        console.log(result,'result')
        if (result !== 200) {
          return
        }
        params.kaData = this.kaData;
        console.info('-------启动测试下发参数----------');
        console.info(params);
        ret = await this.$http.post("/runningTest/addTestRunningParams",params);
      }
      if (flag === 'sure') {
        params.kaData = this.kaData;
        ret = await this.$http.post("/runningTest/addTestRunningParams",params);
      }
      if (ret.code === 200) {
        console.info('------启动成功-------')
        console.info(ret)
        this.testPartList = ret.data;
        this.testPartList[0].testStatus = '试验中';
        this.startButton = false; //启动测试按钮隐藏
        this.startTime = dayjs(new Date()).format('MM-DD HH:mm'); //开始时间
        this.currentPartInfo = [];
        this.currentPartInfo.push(this.testPartList[0]);
        this.setCurrent(this.testPartList[0]);
        this.row = this.testPartList[0]
        this.testParams.testNumber = this.confirmParams.testNumber;
        this.oldTestNumber = this.confirmParams.testNumber;
        this.pauseButton = true;  //暂停测试按钮显示
        this.stopButton = true;   //停止按钮显示
        this.runningTime = 0;
        this.timerClock(this.runningTime); //计时器计算运行时间
        this.$route.query.sign = 'runningTest';
        this.testPartList = ret.data;
        this.getConfimParams();
        this.confirmVisible = false;
        this.remindVisible = false;
        this.checked = false;
        console.info(this.testPartList[0].flagBit);

        if(this.testPartList[0].flagBit.length!=0){
          this.pauseTest();
        }
      }
      this.startLoading = false;
    },
    async suspendTest(){
        let params = {
            "type": "zkGround",
            "ifGround":Number(this.ifGround)
        }
        const res = await this.$http.put("/runningTest/updateRunningTestStatus",params);
        if(res.code === 200){
          this.suspendVisable=false;
          if(this.suspendType == 1){
            this.causeVisible = true;
          }
          this.suspendType = 0;
      }
    },
    //暂停测试
    async pauseTest(){
      let params={};
        params = {
            "instanceId": this.instanceId,
            "status": 'pause',
            "act": 0,
            "dischargeDesc":"",
            "testKind": this.currentPartInfo[0].testKind,
            "type":"runningTest",
            "ifGround":Number(this.ifGround)
        }
        const res = await this.$http.put("/runningTest/updateRunningTestStatus",params);
        if(res.code === 200){
          this.startButton = false;
          this.stopButton = true;
          this.suspendVisable=true;
          this.continueButton = true;
          this.pauseButton = false;
          await this.$http.put('/runningTest/addTestDuration',{"instanceId": this.instanceId, duration: Number(this.runningTime)})
        }

    },
    async goOnTest(){
      this.reslutflag=1;
      this.continueTest();
    },
    //继续测试
    async continueTest(flag){
      this.$flag.setFlag(false)
      let instrumentSign = 1;
      instrumentSign = this.verifyInstrument(); // 考虑第二天继续做试验情况
      if (instrumentSign == 0) {
        return
      }
      let saveFlag = 0;
      const judgeTime = dayjs(this.$route.query.beginTime).format('MM-DD');
      const currentTime = dayjs(new Date()).format('MM-DD')
      let ret =200;
      this.$refs['testParamsForm'].validate((valid) => {
        if (valid) {
          saveFlag = 1;
        }else{
          saveFlag = 0;
        }
      });
      if (saveFlag === 0) {
        this.$message.error('请检查试验参数!');
        return
      }
      // 判断现在时间是否与开始时间同天如果第二天继续昨天的测试
      if (!(dayjs(judgeTime).isSame(dayjs(currentTime))) && this.editDisable === false) {
        const allParams = this.prepareParams();
        ret = await this.determineParameters(allParams,flag);
        console.info('-------下发参数----------');
        console.info(ret)
        if (ret === 200) {
          this.remindVisible = false;
          allParams.kaData = this.kaData;
          let params = {
            info: {
              instance_id: this.instanceId,
              test_number: this.testParams.testNumber,
              voltParamsDemo: JSON.stringify(allParams.voltParamsDemo),
            }
          }
          params.kaData = this.kaData;
          params.atmosphere = allParams.atmosphere;
          console.info('-------保存updateRunningParams下发参数----------');
          console.info(params);
          const result = await this.$http.put("/runningTest/updateRunningParams",params);
          this.getConfimParams();
          ret = result.code;
          this.editDisable = true;
        }
      }
      if (ret !== 200) {
        return
      }
      ret = await this.changeTestNumber();
      if (ret === 200) {
        let params;
        if (this.opcStatusVisable == true) { // 因为分合闸状态切换之后进行继续
          params = {
          "type": "opcStatus",
          "status": 'close',
          "dischargeDesc":"",
          "ifGround":Number(this.ifGround),
          "act": 0
          }
        } else {
          params = {
            "instanceId": this.instanceId,
              "status": 'continue',
              "dischargeDesc":"",
              "ifGround":Number(this.ifGround),
              "act": 1,
              "testKind": this.currentPartInfo[0].testKind,
              "type":"runningTest",
              "chargeTime":this.liEquipParams.chargeTime
          }
          if(this.reslutflag==1){
            params.dischargeDesc=this.failCase;
          }
        }
        console.info(params);
        
        //if(res.code === 200){
          this.ifGround="0"
          this.reslutflag=0
          this.opcStatusVisable = false;
          this.startButton = false;
          this.causeVisible = false;
          this.$refs.audio.pause();
          this.stopButton = true;
          this.continueButton = false;
          this.pauseButton = true;
        //}
        const res = await this.$http.put("/runningTest/updateRunningTestStatus",params);
      }
      this.$flag.setFlag(false)
    },
    //停止测试
    async stopTest(){
      this.successInfo = '实验结束！'
      let params;
      let res;
      if (this.stopVisible === true) { // 如果报警界面出现，保存报警原因: 试验方或试品原因
        params = {
          testKind: this.currentPartInfo[0].testKind,
          dischargeRemark: this.causeVisible,
          recId: this.recordId
        }
        res = await this.$http.put("/runningTest/addExceptionCauses", params,);
        if (res.code !== 200) {
          return
        }
      }
      params = {
          "instanceId": this.instanceId,
          "status": 'stop',
          "dischargeDesc":"",
          "act": 2,
          "ifGround":Number(this.ifGround),
          "testKind": this.currentPartInfo[0].testKind,
          "type":"runningTest"
      }
      // if(this.reslutflag==1){
      //   params.dischargeDesc=this.failCase;
      // }
      console.info(params);
      res = await this.$http.put("/runningTest/updateRunningTestStatus",params); // 下发停止
      if(res.code === 200){
        this.ifGround="0";
        // this.reslutflag=0;
        this.causeVisible = false;
        this.topVisible = true;
        this.startButton = true;
        this.stopButton = false;
        this.continueButton = false;
        this.pauseButton = false;
        this.stopVisible = false;
        this.successVisible = true;
        this.testParams.testNumber = '';
        this.instanceId = '';
      }
      this.$flag.setFlag(false)
    },
    // 检查设备里工频和雷电设备是否在线
    verifyInstrument() {
      for(let i=0; i<this.instrumentData.length; i++){
        for (let j=0; j<this.instrumentData[i].length; j++) {
          if(this.instrumentData[i][j].kind_name === '工频耐受电压试验设备' && this.instrumentData[i][j].online_status === '离线'){
            this.$message.error(this.instrumentData[i][j].instr_name + '仪器处于离线状态!');
            return 0;
          }
          if(this.instrumentData[i][j].kind_name === '雷电冲击耐受电压试验设备' && this.instrumentData[i][j].online_status === '离线'){
            this.$message.error(this.instrumentData[i][j].instr_name + '仪器处于离线状态!');
            return 0;
          }
        }
      }
      return 1;
    },
    //验证
    verify(formName){
      let instrumentSign = 1;
      instrumentSign = this.verifyInstrument();
      this.$refs[formName].validate((valid) => { // 校验试验参数是否输入
        if(valid) {
          if(instrumentSign === 1){
            this.confirmVisible = true;
            this.getConfimParams();
          }
        }
      });
    },
    // 测试结束后再次确认仪器状态
    async afterCofirmInstStatus () {
      this.$flag.setFlag(false)
      let instrument =[];
      for (let i=0; i<this.confirmInstrument.length; i++){
        instrument.push({
          instance_id: this.instanceId,
          instrument_id: this.confirmInstrument[i].instr_id,
          status: Number(this.confirmInstrument[i].status),
          address: this.confirmInstrument[i].address
        }) 
      }
      const params = {
        instrument: instrument,
        info: {
          test_number: this.testParams.testNumber,
          'instanceId': this.instanceId,
          duration: Number(this.runningTime)
        }
      }
      console.info(this.testParams.testNumber);
      console.info(this.instanceId);
      const ret = await this.$http.put("/runningTest/upInstrumentRunningData",params);
      if (ret.code === 200) {
        this.successVisible = false;
        this.instanceId = '';
        this.testParams.testNumber = '';
      }
      setTimeout(()=> {this.successInfo = '恭喜，试验完成！'},2000)
         
      
    },
    // 检测仪器是否勾选异常，确认是否开启测试
    beforStartTest(){
      let index = this.confirmInstrument.findIndex((value) => {
        return value.status == '0';
      });
      if (index !== -1) {
        this.innerVisible = true;
        return;
      }
      this.saveValidate();
    },
    // 保存前的校验
    saveValidate(flag){
      let saveFlag = 0;
      this.$refs['confirmParams'].validate((valid) => {
        if (valid) {
          saveFlag = 1;
        }else{
          saveFlag = 0;
        }
      });
      if (saveFlag === 0) {
        this.$message.error('您未填写委试号!');
        return
      }
      if (this.showliEquip === true) {
        this.$refs['liEquipForm'].validate((valid) => {
          if (valid) {
            saveFlag = 1;
          }else{
            saveFlag = 0;
          }
        });
        if (saveFlag === 0) {
          this.$message.error('您未填写完整参数配置中雷电部位电压参数!');
          return
        }
      }
      if (this.showACEquip === true) {
        this.$refs['acEquipForm'].validate((valid) => {
          if (valid) {
            saveFlag = 1;
          }else{
            saveFlag = 0;
          }
        });
        if (saveFlag === 0) {
          this.$message.error('您未填写完整参数配置中工频耐受电压试验部位电压参数!');
          return
        }
      }
      if (this.showACWet === true) {
        this.$refs['acWetEquipForm'].validate((valid) => {
          if (valid) {
            saveFlag = 1;
          }else{
            saveFlag = 0;
          }
        });
        if (saveFlag === 0) {
          this.$message.error('您未填写完整参数配置中工频耐受电压试验(湿)部位电压参数!');
          return
        }
      }
      if (this.showDefend === true) {
        this.$refs['defendParams'].validate((valid) => {
          if (valid) {
            saveFlag = 1;
          }else{
            saveFlag = 0;
          }
        });
        if (saveFlag === 0) {
          this.$message.error('您未填写完整气候防护参数!');
          return
        }
      }
      if (this.continueButton === true) {
        this.continueTest(flag);
      } else {
        this.saveInstance(flag);
      }
    },
    // 获取仪器状态显示
    async getInstrumentList() {
      const params = {
        instanceId: this.instanceId
      }
      const ret = await this.$http.get("/runningTest/getInstrumentData",{params})
      this.instrumentData = ret.result;
    }
	},
	mounted() {
    this.init();
    Bus.$on('reciveEvent',(reciveMessage) => {
      this.getTestRecordData(reciveMessage);
    });
    Bus.$on('reciveInstrEvent',(reciveMessage) => {
      this.getInstrumentList();
    });
    console.log(this.$flag.flag);
    if(this.$flag.flag) {
      this.getTestRecordData(this.$reciveEvent);
    }
    // 离开页面销毁监听
    this.$once('hook:beforeDestroy', () => {
      Bus.$off(['reciveEvent']);
      Bus.$off(['reciveInstrEvent']);
    });
	}
};
</script>
<style lang="scss" scoped>
@import "./TestPlanRunning.scss";
</style>